import {ToastController } from 'ionic-angular';
import { Injectable } from '@angular/core';

@Injectable()
export class ControlsCheck {
  constructor(private toastCtrl: ToastController,){

  }
  check(controls,msgOption){
    for(let key in controls){
      if(controls[key].invalid){
        this.toastMsg(msgOption[key])
        return false;
      }
    }
    return true
  }

  toastMsg(message:string){
    let toast = this.toastCtrl.create({
      message: message,
      position: 'middle',
      duration: 3000
    })
    toast.present();
  }
}
